function sort(nums) {
  const n = nums.length;
  let sortIndex = 0;

  while (sortIndex < n) {
    let minIndex = sortIndex;
    for (let i = minIndex; i < n; i++) {
      if (nums[minIndex] > nums[i]) {
        minIndex = i;
      }
    }
    [nums[minIndex], nums[sortIndex]] = [nums[sortIndex], nums[minIndex]];
    sortIndex++;
  }
  console.log('选择排序', nums);
}
sort([5, 2, 3, 1]);
